#pragma once
#include "../functions.h"

void trigonometric() {
  const short operation = get_choice(
      "Операция", {"Синус", "Косинус", "Тангенс", "Котангенс", "Арксинус",
                   "Арккосинус", "Арктангенс", "Арккотангенс"});
  const double alpha = numeric_input("Угол");
  const double radians = convert_degree_to_radians(alpha);

  string function;
  double operation_result;

  switch (operation) {
    case 1:
      function = "sin";
      operation_result = sin(radians);
      break;
    case 2:
      function = "cos";
      operation_result = cos(radians);
      break;
    case 3:
      function = "tg";
      operation_result = tan(radians);
      break;
    case 4:
      function = "ctg";
      operation_result = 1 / tan(radians);
      break;
    case 5:
      function = "arcsin";
      operation_result = asin(radians);
      break;
    case 6:
      function = "arccos";
      operation_result = acos(radians);
      break;
    case 7:
      function = "arctg";
      operation_result = atan(radians);
      break;
    case 8:
      function = "arcctg";
      operation_result = 1 / atan(radians);
      break;
  }

  string result = isnan(operation_result)   ? "∅"
                  : isinf(operation_result) ? "∞"
                                            : "";

  if (!result.empty())
    print_equation({function, "(", alpha, ")", result});
  else
    print_equation({function, "(", alpha, ")", operation_result});
}